﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HPPNet;

namespace HPPClientLibrary.DownLoad
{
    public class Buffer
    {
        private string _saveFilePath;
        private byte[] _content;
        private string _hash;
        private int _startPos;//写入文件的起始位置
        private int _blockID;//写入文件的块号
        private bool _isBufferFinish;//一块是否下载完成的标志，只有下载完才写入磁盘

        /// <summary>
        /// 供BufferPool使用的token
        /// </summary>
        private int _token;

        public Buffer(int token)
        {
            Token = token;
            _content = new byte[BasicSetting.BlockSize];
        }


        public byte[] Content
        {
            get { return _content; }
            set { _content = value; }
        }

        public int StartPos
        {
            get { return _startPos; }
            set { _startPos = value; }
        }
        public string SaveFilePath
        {
            get { return _saveFilePath; }
            set { _saveFilePath = value; }
        }

        /// <summary>
        /// 供BufferPool使用的token
        /// </summary>
        public int Token
        {
            get { return _token; }
            private set { _token = value; }
        }

        public string Hash
        {
            get { return _hash; }
            set { _hash = value; }
        }
        public int BlockID
        {
            get { return _blockID; }
            set { _blockID = value; }
        }
        public bool IsBufferFinish
        {
            get { return _isBufferFinish; }
            set { _isBufferFinish = value; }
        }
    }
}
